home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / SoundApps / aa_m68k_Only / Sonogram / convh2l.c next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  1.4 KB  |  57 lines

  1. //
  2. //    convh2l    -    A sound converter
  3. //
  4. //    convh2l takes a snd file as input and writes a 22kHz
  5. //    stereo 16 bit linear soundfile
  6. //
  7. //        Ver. 1.0
  8. //
  9. //    v1.0 1991/3/18
  10. //
  11. //    HiroshiMomose
  12. //        Zoology, UCD, Davis, CA 95616   hmomose@ucdavis.edu
  13. //
  14. //    To compile, type : cc -O -g -o convh2l convh2l.c -lsys_s
  15. //
  16. //    This program is mostly based on converttest.c
  17. //    found in /Nextdeveloper/Examples/Sound
  18.  
  19. #define pname  "convh2l"
  20. #define title ("convh2l.c - converts a .snd file to 22kHz stereo 16 bit linear")
  21.  
  22. #import <sound/sound.h>
  23. #import <stdio.h>
  24.  
  25. check_error(int err)
  26. {
  27.     if (err) {
  28.     fprintf(stderr, "Error : %s\n",SNDSoundError(err));
  29.     exit(1);
  30.     }
  31.     return err;
  32. }
  33.  
  34. main (int argc, char *argv[])
  35. {
  36.     SNDSoundStruct *s1, *s2;
  37.     SNDSoundStruct header = {
  38.     SND_MAGIC, 0, 0, SND_FORMAT_LINEAR_16, (int)SND_RATE_LOW, 2, "" };
  39.  
  40.     if( argc != 3 ) {
  41.         fprintf( stderr, "%s\n\n", title );
  42.         fprintf( stderr, "Usage : %s infile outfile\n\n\t", pname );
  43.         fprintf( stderr, "infile must be a .snd file\n\t" );
  44.         fprintf( stderr, "outfile will be a 22kHz 16bit linear stereo .snd file\n\t" );
  45.         fprintf( stderr, "Doesn't check if outfile already exists. So be careful.\n\n" );
  46.         fprintf( stderr, "Sample operation : %s in.snd out.snd\n", pname );
  47.         exit( -1 );
  48.     }    
  49.     check_error(SNDReadSoundfile(argv[1],&s1));
  50.     s2 = &header;
  51.     check_error(SNDConvertSound(s1,&s2));
  52.     check_error(SNDWriteSoundfile(argv[2],s2));
  53.     exit(0);
  54. }
  55.  
  56.  
  57.